package studentproject.main.service;


import studentproject.main.dao.TeacherDao;
import studentproject.main.domain.Teacher;

import java.util.ArrayList;

public class TeacherService{
    private static TeacherDao teacherDao = new TeacherDao();
    public int isExist(String id) {
        int index = -1;
        ArrayList<Teacher> list = teacherDao.find();
        for (int i = 0; i < list.size(); i++) {
            Teacher teacher = list.get(i);
            if(id.equals(teacher.getId())){
                index = i;
                return index;
            }
        }
        return index;
    }

    public boolean add(Teacher teacher) {
        boolean flag = teacherDao.add(teacher);
        return flag;
    }

    public boolean update(int index,Teacher teacher) {
        boolean flag = teacherDao.update(index,teacher);
        return flag;
    }

    public boolean delete(int index) {
        boolean flag = teacherDao.delete(index);
        return flag;
    }

    public boolean getList() {
        boolean flag = teacherDao.getList();
        return flag;
    }

    public ArrayList<Teacher> find() {
        return teacherDao.find();
    }
}
